package ntd.util.modular.ai.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import ntd.util.modular.ai.entity.Ai;
import ntd.util.modular.ai.service.AiService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.sql.SQLException;

/**
 * Author: yyd
 * Date: 2023-10-24 14:12
 */
@Api(tags = {"AI分析服务器配置"})
@RestController
@RequestMapping("/ai/server")
public class AiController {

    @Autowired
    AiService aiService;

    @GetMapping()
    @ApiOperation("列表")
    public Object server() throws SQLException {
        return aiService.server();
    }

    @PostMapping()
    @ApiOperation("添加")
    public Object add(@Valid Ai ai) throws SQLException {
        return aiService.add(ai);
    }

    @PutMapping("{id}")
    @ApiOperation("编辑")
    public Object edit(@PathVariable String id, @Valid Ai ai) throws SQLException {
        return aiService.edit(id, ai);
    }


    @DeleteMapping("{id}")
    @ApiOperation("删除")
    public Object delete(@PathVariable String id) throws SQLException {
        return aiService.delete(id);
    }

    @GetMapping("{id}")
    @ApiOperation("详情")
    public Object detail(@PathVariable String id) throws SQLException {
        return aiService.detail(id);
    }
}
